//
//  FirstViewController.m
//  UI09_homework
//
//  Created by aaaaaa on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "CustomLTView.h"

@interface FirstViewController ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate>

@property (nonatomic ,retain) UIButton *headButton;

@end

@implementation FirstViewController

- (void)viewDidLoad{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"第一页";
    
    [self createSubViews];
    
 }

- (void)createSubViews{
    
    self.headButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.headButton setImage:[UIImage imageNamed:@"image.jpg"] forState:UIControlStateNormal];
    self.headButton.frame = CGRectMake(314 / 2, 80, 100, 100);
    [self.view addSubview:self.headButton];
    [self.headButton addTarget:self action:@selector(headAction:) forControlEvents:UIControlEventTouchUpInside];
    
    CustomLTView *user = [[CustomLTView alloc] initWithFrame:CGRectMake(70, 150 + 80, 280, 30)];
    user.lableText = @"用户名:";
    user.textFieldPlaceHolder = @"请输入用户名";
    [self.view addSubview:user];
    [user release];
    
    CustomLTView *password = [[CustomLTView alloc] initWithFrame:CGRectMake(70, 220 + 80, 280, 30)];
    password.lableText = @"密码:";
    password.textFieldPlaceHolder = @"请输入密码";
    password.secureTextEntry = YES;
    [self.view addSubview:password];
    [password release];
    
    UIButton *login = [UIButton buttonWithType:UIButtonTypeSystem];
    login.frame = CGRectMake(140, 320 + 80, 50, 30);
    [login setTitle:@"登录" forState:UIControlStateNormal];
    [self.view addSubview:login];
    [login addTarget:self action:@selector(loginAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *cancel = [UIButton buttonWithType:UIButtonTypeSystem];
    cancel.frame = CGRectMake(240, 320 + 80, 50, 30);
    [cancel setTitle:@"取消" forState:UIControlStateNormal];
    [self.view addSubview:cancel];
    [cancel addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)headAction:(UIButton *)button{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    picker.delegate = self;
    picker.allowsEditing = YES;
    [self presentViewController:picker animated:YES completion:^{
        
        
    }];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [self.headButton setImage:image forState:UIControlStateNormal];
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}


- (void)loginAction:(UIButton *)button{

    
}

- (void)cancelAction:(UIButton *)button{


}



@end
